

        var autoCutInt = null;
        var cutActive = 0;
        var prevent = false;
        var clicked = false;
        var prvntTmout = null;
        var updateTxtDelay = null;
        var ready = false;

        var scaling = null;
        var scaleDelay = null;
        var prjctSwiper = new Swiper('.prjctSwiper',{
            centeredSlides:true,
            loop:true,
            slidesPerView:'auto',
            speed:800,
            on: {
                touchStart: function(event){
                    var evt = event || window.event;
                    console.log(evt.target);
                },
            },
        })
        
        $(document).ready(function(){
            
            var pLength = $('.cutPics .palace .lft .box').length;
            $('.cutPics .palace .lft .box:eq(0)').addClass('enter active noTrstn');
            $('.cutPics .palace .rht .box:eq(0)').addClass('enter active noTrstn');
            $('main .cutPics .loc ul li:eq(0)').addClass('active');
            $('.projects.switch .contn nav .choose ul li:eq(0)').addClass('active');
            var ttlTime = $('.loading .txt p').length * .4;

            $('.loading .line')[0].style.cssText = 'animation: loading ' + (ttlTime + .6) + 's ease-in-out forwards;transition: background .3s ' + (ttlTime * .8) + 's;'
            for(var l = 0;l < $('.loading .txt p').length;l++){
                $('.loading .txt p')[l].style.transitionDelay = (ttlTime * .8) + 's,' + (l * .4) + 's';
            }
            setTimeout(function(){
                $('.loading').addClass('finish');
            },ttlTime * 1000)
            setTimeout(function(){
                $('.loading').css('pointer-events','none');
            },ttlTime * 1000 + 900)
            setTimeout(function(){
                $('.cutPics .palace .box').removeClass('noTrstn');
                $('.loading,.loading .txt').addClass('active');
            },10)  
            setTimeout(function(){
                $('main .cutPics .ttls').css('opacity','1');
                $('main .cutPics .ttls .box:eq(0)').addClass('active');
            },510)
            function autoCut(ind){
                $('.cutPics .palace .box').removeClass('hidden');
                if(clicked && $('.cutPics .palace .lft .box:eq(' + ind + ')')[0].className.indexOf('leave') >= 0){
                    $('.cutPics .palace .lft .box:eq(' + ind + ')').removeClass('leave');
                    $('.cutPics .palace .rht .box:eq(' + ind + ')').removeClass('leave');
                    $('.cutPics .palace .lft .box:eq(' + cutActive + ')').removeClass('enter');
                    $('.cutPics .palace .rht .box:eq(' + cutActive + ')').removeClass('enter');
                    $('.cutPics .palace .lft .box').removeClass('active');
                    $('.cutPics .palace .rht .box').removeClass('active');
                    $('.cutPics .palace .lft .box:eq(' + ind + ')').addClass('active');
                    $('.cutPics .palace .rht .box:eq(' + ind + ')').addClass('active');
                    cutActive = ind;
                    $('main .cutPics .loc ul li').removeClass('active');
                    $('main .cutPics .loc ul li:eq(' + ind + ')').addClass('active');
                    return false;
                }else{
                    $('.cutPics .palace .box').removeClass('active');
                    $('main .cutPics .loc ul li').removeClass('active');
                    $('main .cutPics .ttls .box').removeClass('active');
                    $('.cutPics .palace .lft .box:eq(' + cutActive + ')').addClass('leave');
                    $('.cutPics .palace .rht .box:eq(' + cutActive + ')').addClass('leave');
                }
                
                if(clicked){
                    cutActive = ind;
                    clicked = false
                    console.log(ind);
                }else{
                    if(cutActive == pLength - 1){
                        cutActive = 0;
                    }else{
                        cutActive++;
                    }
                }
                updateTxtDelay = setTimeout(function(){
                    $('main .cutPics .ttls .box:eq(' + cutActive + ')').addClass('active');
                },1200)
                $('main .cutPics .loc ul li:eq(' + cutActive + ')').addClass('active');
                $('.cutPics .palace .lft .box:eq(' + cutActive + ')').addClass('active');
                $('.cutPics .palace .rht .box:eq(' + cutActive + ')').addClass('active');
                $('.cutPics .palace .lft .box:eq(' + cutActive + ')').addClass('enter');
                $('.cutPics .palace .rht .box:eq(' + cutActive + ')').addClass('enter');
                prevent = true;
                prvntTmout = setTimeout(function(){
                    prevent = false;
                    for(var b = 0;b < $('.cutPics .palace .box').length;b++){
                        if($('.cutPics .palace .box')[b].className.indexOf('active') < 0){
                            $('.cutPics .palace .box:eq(' + b + ')').addClass('hidden');
                            $('.cutPics .palace .box:eq(' + b + ')').removeClass('enter');
                            $('.cutPics .palace .box:eq(' + b + ')').removeClass('leave');
                        }
                    }
                },1010);
            }
            autoCutInt = setInterval(function(){
                autoCut();
            },5000)

            $('main .cutPics .loc ul li').click(function(){
                var ind = $(this).index();
                console.log(ind);
                if(cutActive != ind){
                    clearInterval(autoCutInt);
                    clearTimeout(prvntTmout);
                    clicked = true;
                    prevent = false;
                    autoCut(ind);
                    autoCutInt = setInterval(function(){
                        autoCut();
                    },5000)
                }
            })
            
            $('.projects.switch .contn .btn').click(function(){
                if($(this)[0].className.indexOf('prev') >= 0){
                    prjctSwiper.slidePrev(); 
                }else{
                    prjctSwiper.slideNext();
                }
            })
            $('.projects.switch .contn .swiper').mouseenter(function(){
                $(this).addClass('on');
                secPrevent = false;
                console.log('c')
            })
            $('.projects.switch .contn .swiper').mouseleave(function(){
                $(this).removeClass('on');
            })
            $('.projects.switch .contn nav .choose ul li p').click(function(){
                var type = $(this).attr('data-categories');
                console.log(type);
                $('.projects.switch .contn nav .choose ul li').removeClass('active');
                $(this).parent().addClass('active');
                $('.projects.switch .contn .swiper').addClass('disappear');
                setTimeout(function(){
                    $('.projects.switch .contn .swiper .swiper-slide').removeClass('hidden');
                    for(var c = 0;c < $('.projects.switch .contn .swiper .name').length;c++){
                        var dataType = $('.projects.switch .contn .swiper .name:eq(' + c + ')').attr('data-categories');
                        console.log(dataType)
                        if( dataType != type && type != 'all'){
                            $('.projects.switch .contn .swiper .name:eq(' + c + ')').parents('.swiper-slide').addClass('hidden');
                        }else{
                            $('.projects.switch .contn .swiper .name:eq(' + c + ')').parents('.swiper-slide').removeClass('hidden');
                        }
                    }
                    prjctSwiper.update();
                    $('.projects.switch .contn .swiper').removeClass('disappear');
                },510)
            })
            $('.projects.switch .swiper .swiper-slide').click(function(){
                if(scaleDelay) return false;
                $('.scale img').attr('src',$(this).find('img').attr('src'));
                $('.scale').css('top',$(this)[0].getBoundingClientRect().top + 'px');
                var scaleDelayScds = $(this)[0].className.indexOf('active') >= 0?10:810;
                scaleDelay = setTimeout(function(){
                    $('.scale').addClass('move');
                },scaleDelayScds)
                setTimeout(function(){
                    window.location.href = 'case.html';
                },1000 + scaleDelayScds);
                if($(this)[0].className.indexOf('prev') >= 0){
                    prjctSwiper.slidePrev();
                }else if($(this)[0].className.indexOf('next') >= 0){
                    prjctSwiper.slideNext();
                }
                console.log($(this)[0].getBoundingClientRect().top,$(this)[0].getBoundingClientRect().left);
                
                
            })
            $('.projects.switch .contn .swiper .swiper-slide .box .pic').mouseup(function(){
                console.log('msdn');
                $(this).parents('.swiper-slide').addClass('msdn');
            })

            $('header .logo .txt').click(function(){
                if(window.innerWidth > 1024){
                    $('.btmLft .loc ul li')[$('section.projects').index()].click();
                }else{
                    scrollToCertain($('section.projects'));
                }
                return false;
            })
        })
